package com.wd.live.viewmodel;

import android.app.Application;

import androidx.annotation.NonNull;
import androidx.lifecycle.MutableLiveData;

import com.wd.live.base.BaseViewModel;
import com.wd.live.bean.MusicBeen;
import com.wd.live.model.HttpUtils;

import io.reactivex.Observer;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.Disposable;
import io.reactivex.schedulers.Schedulers;

public class MusicViewModel extends BaseViewModel {
    public MusicViewModel(@NonNull Application application) {
        super(application);
    }
    MutableLiveData<MusicBeen> MusicData=new MutableLiveData<>();

    public MutableLiveData<MusicBeen> getMusicData(int page,int size) {
        HttpUtils.getHttpUtils().getApi().findMusicList(page, size)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Observer<MusicBeen>() {
                    @Override
                    public void onSubscribe(Disposable d) {

                    }

                    @Override
                    public void onNext(MusicBeen value) {
                MusicData.postValue(value);
                    }

                    @Override
                    public void onError(Throwable e) {

                    }

                    @Override
                    public void onComplete() {

                    }
                });
        return MusicData;
    }
}
